﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MaxLeaf.Common;
using MaxLeaf.DB;
using System.Data;
using MySql.Data.MySqlClient;

namespace MaxLeaf.DAL.Web
{
  
    public class mary_icdisplyDAL : BaseDAL
    {
        public mary_icdisplyDAL()
            : base()
        {
            strTableName = "mary_icdisply";
            strKeyFieldName = "FInterID";
            strFieldNames = "FNumber,FName,FSysTypeID,FItemTypeID";
        }
        //protected override void DAL_GetFieldData(DBAccess dbOrgCon, DBAccess dbDestCon, string strFieldName, DataRow drOrgData, DataRow drDestData)
        //{
        //    if (strFieldName.Equals("FDepartmentID", StringComparison.InvariantCultureIgnoreCase))
        //    {

        //        string strFUnitGroupID = GetFDepartmentID(dbOrgCon, dbDestCon, CvtFunc.ToString(drOrgData[strFieldName]));
        //        if (strFUnitGroupID.Length == 0)
        //        {
        //            drDestData[strFieldName] = DBNull.Value;
        //        }
        //        else
        //        {
        //            drDestData[strFieldName] = strFUnitGroupID;


        //        }

        //    }
        //    else
        //    {
        //        base.DAL_GetFieldData(dbOrgCon, dbDestCon, strFieldName, drOrgData, drDestData);
        //    }
        //}

        //private string GetFDepartmentID(DBAccess dbOrgCon, DBAccess dbDestCon, string strOrgFDepartmentID)
        //{
        //    t_departmentDAL dal = new t_departmentDAL();


        //    return dal.FDepartmentID(dbOrgCon, dbDestCon, strOrgFDepartmentID);


        //}

        protected override DataTable DAL_GetData(DBAccess dbOrgCon, DBAccess destCon, int intdataType, object objParam)
        {
            GetDataType dataType = (GetDataType)intdataType;

            if (dataType == GetDataType.OrgData)
            {
                return Getmary_icdisply(dbOrgCon, CvtFunc.ToString(objParam));
            }


            return base.DAL_GetData(dbOrgCon, destCon, intdataType, objParam);
        }



        private DataTable Getmary_icdisply(DBAccess dbOrgCon, string strFInterID)
        {
            DataTable dtmary_icdisply = null;
            if (dtmary_icdisply == null)
            {
                dtmary_icdisply = dbOrgCon.GetTableData("icdisply", new Dictionary<string, object> { { "FInterID", strFInterID } });

            }
            return dtmary_icdisply;
        }


        internal string Get_FInterID(DBAccess dbOrgCon, DBAccess dbDestCon, string strOrgFInterID)
        {
            if (strOrgFInterID.Equals("0") || strOrgFInterID.Length == 0)
            {
                return "0";
            }

            Update(dbOrgCon, dbDestCon, strOrgFInterID);

            return strOrgFInterID;
        }
    }
}